package fantasyday.wowzolo.ArmoryParse;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.io.InputStream;
import java.io.IOException;
import java.net.URLConnection;
import java.net.URL;
import java.net.MalformedURLException;

import fantasyday.wowzolo.util.WowConstans;

/**
 * Created by IntelliJ IDEA.
 * User: Zolo
 * Date: 2009-1-22
 * Time: 0:25:12
 * To change this template use File | Settings | File Templates.
 */
public class ArmoryParser {
    public Document parseInputStream(InputStream inputStream) throws DocumentException {
        SAXReader reader = new SAXReader();
        Document document = reader.read(inputStream);
        return document;
    }

    public void parseCharacter(String characterName, String realm) throws IOException, DocumentException {
        String init_url = WowConstans.US_REALM_ARMORY + "/" + WowConstans.US_REALM_ARMORY + "?r=" + realm + "&n=" + characterName;

            URL url = new URL("init_url.replace(' ','+')");

        URLConnection conn = url.openConnection();
                    conn.setRequestProperty("user-agent", WowConstans.USER_AGENT);
                    InputStream is = conn.getInputStream();

        Document document = parseInputStream(is);

        Element root = document.getRootElement();
        System.out.println(root.getName());
                        
        }




    }
